package cn.zhxu.data.snack3;

import org.noear.snack.annotation.ONodeAttr;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Objects;

public class AnnoTimeObject {

    @ONodeAttr(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime dateTime;

    @ONodeAttr(format = "yyyy/MM/dd")
    private LocalDate date;

    @ONodeAttr(format = "HH:mm:ss")
    private LocalTime time;

    public AnnoTimeObject() {
    }

    public AnnoTimeObject(LocalDateTime dateTime) {
        this.dateTime = dateTime;
        this.date = dateTime.toLocalDate();
        this.time = dateTime.toLocalTime();
    }

    public LocalDate getDate() {
        return date;
    }

    public void setDate(LocalDate date) {
        this.date = date;
    }

    public LocalDateTime getDateTime() {
        return dateTime;
    }

    public void setDateTime(LocalDateTime dateTime) {
        this.dateTime = dateTime;
    }

    public LocalTime getTime() {
        return time;
    }

    public void setTime(LocalTime time) {
        this.time = time;
    }

    @Override
    public boolean equals(Object object) {
        if (object == null || getClass() != object.getClass()) return false;
        AnnoTimeObject that = (AnnoTimeObject) object;
        return Objects.equals(dateTime, that.dateTime) && Objects.equals(date, that.date) && Objects.equals(time, that.time);
    }

    @Override
    public int hashCode() {
        return Objects.hash(dateTime, date, time);
    }

    @Override
    public String toString() {
        return "AnnoTimeObject{" +
                "dateTime=" + dateTime +
                ", date=" + date +
                ", time=" + time +
                '}';
    }

}
